package bilibli;

import bilibli.pojo.Video;
import bilibli.utils.DowloadUtil;
import bilibli.utils.ParseVideoUtil;

import java.util.Scanner;

public class CreeperMain {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的下载路径");
        String path = scanner.next();
        System.out.println("请选择下载模式");
        System.out.println("1、单下载 \t 2、多选择");
        switch (scanner.next()) {
            case "1":
                System.out.println("请输入av号");
                String one = scanner.next();
                //获取video对象
                Video video = ParseVideoUtil.parseVideo(String.valueOf(one));
                if (video != null) {
                    //获取真正的URL
                    String url = ParseVideoUtil.getURL(video);
                    //获取真正的视频json数据
                    String[] videoUrl = ParseVideoUtil.getVideoUrl(url);
                    DowloadUtil.dowload(video, videoUrl,path);
                }
            case "2":
                //起点AVid号
                System.out.println("请输入起点AVid号");
                String next = scanner.next();
                //终点AVid号
                System.out.println("请输入终点AVid号");
                String end = scanner.next();
                for (int i = Integer.parseInt(next); i <= Integer.parseInt(end); i++) {
                    //获取video对象
                    Video video1 = ParseVideoUtil.parseVideo(String.valueOf(i));
                    if (video1 != null) {
                        //获取真正的URL
                        String url = ParseVideoUtil.getURL(video1);
                        //获取真正的视频json数据
                        String[] videoUrl = ParseVideoUtil.getVideoUrl(url);
                        DowloadUtil.dowload(video1, videoUrl,path);
                    } else {
                        continue;
                    }
                }


        }

    }


}
